package com.zmj.framework.config;

import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Prometheus 配置类
 * @author CP
 * @Date: 2021/01/01 8:56
 */
@Configuration
public class PrometheusConfiguration {

    @Value("${spring.application.name:}")
    private String applicationName;

    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer() {
        return (registry) -> registry.config()
            .commonTags("application", applicationName);
    }
}
